1. /* snmchkar.cpp by K.Tsuru */
  2. // function ID = 102 DRADIX, BRADIX
  3. /***************************************************
  4. SNumber class
  5. It provides the information of figure position.
  6. The normalization has to be done.
  7. By the argument id the place where an error occures
  8. can be identified in debug.
  9. ***************************************************/
  10. #ifndef SN_H
  11. #include "sn.h"
  12. #endif
  13. static const char* const func = "CheckArray";
  14. void SNumber::CheckArray(int id){
  15. if(sign == UNDECIDED ) SetError(UNDEC_VALUE, func, id);
  16. uint fsz = figure.size();
  17. #ifndef NDEBUG
  18. if(fsz < minArraySize){
  19. fprintf(stderr, " fsz = %u\n", fsz);
  20. SetError(FATAL, func, id);;
  21. }
  22. #endif
  23. const fType* fe = figure.Elements();
  24. aTail=0;
  25. while( (aTail < fsz) && (fe[aTail] == 0) ) aTail++; //from the tail
  26. if( aTail == fsz ){ //All the elements are zero.
  27. SetZero(); return;
  28. }
  29. //Here, there must be non-zero element(s) anywhere.
  30. aHead = fsz-1;
  31. while( (fe[aHead] == 0) && aHead) aHead--; //from the head
  32. // DoCutDown() does not change the values of aHead and aTail.
  33. if( (2u*(aHead+1) <= fsz) && (CutDown() == ENABLE) ) DoCutDown();
  34. //for debug
  35. #ifndef NDEBUG
  36. fe = figure.Elements();
  37. if(fe[aHead] && (sign == ZERO) ){//figure is contradictory to the sign.
  38. SetError(FATAL, func, id);
  39. }
  40. fType radix = Radix();
  41. for(uint i = aTail; i<= aHead; i++){
  42. if(fe[i] >= radix){ //not be normalized
  43. fprintf(stderr, "figure[%u] = %u, id = %d\n", i, fe[i], id);
  44. SetError(FATAL,"CheckArray()",id);
  45. }
  46. }
  47. #endif
  48. }

snmchkar.cpp : last modifiled at 2017/03/13 14:32:01(1,558 bytes)
created at 2016/04/11 11:36:47
The creation time of this html file is 2017/10/27 10:59:17 (Fri Oct 27 10:59:17 2017).